{% extends "base.html" %}
{% block title %}Attacks{% endblock %}
{% block content %}
    <div class="row">
        <div class="small-4 large-centered columns">
            <h2>Attacks Report</h2>
        </div>
    </div>
    <div class="row">
        <div class="small-12 large-centered columns">
            <div class="row">
                <div class="small-4 columns">
                    <h4>Search Filters</h4>
                </div>
            </div>
            <form id="attack-filter" action="" method="get">
                <div class="row">
                    <div class="small-3 columns">
                        <label>Sensor</label>
                    </div>
                    <div class="small-2 columns">
                        <label>Honeypot</label>
                    </div>
                    <div class="small-2 columns">
                        <label>Date</label>
                    </div>
                    <div class="small-1 columns">
                        <label>Port</label>
                    </div>
                    <div class="small-2 pull-2 columns">
                        <label>IP Address</label>
                    </div>
                </div>
                <div class="row">
                    <div class="small-3 columns">
                        <select name="identifier">
                            <option value="">All</option>
                            {% for s in sensors %}
                            <option {% if s.uuid == identifier %}selected{% endif %} value="{{ s.uuid }}">{{ s.hostname }}</option>
                            {% endfor %}
                        </select>
                    </div>
                    <div class="small-2 columns">
                        <select name="honeypot">
                            <option value="">All</option>
                            {% for pot in settings.supported_honeypots %}
                            <option {% if pot == honeypot %}selected{% endif %} value="{{ pot }}">{{ pot }}</option>
                            {% endfor %}
                        </select>
                    </div>
                    <div class="small-2 columns">
                        <input type="text" name="timestamp" value="{{ timestamp }}" placeholder="MM-DD-YYYY" />
                    </div>
                    <div class="small-1 columns">
                        <input type="text" name="destination_port" value="{{ destination_port }}" placeholder="445" />
                    </div>
                    <div class="small-2 columns">
                        <input type="text" name="source_ip" value="{{ source_ip }}" placeholder="8.8.8.8" />
                    </div>
                    <div class="small-2 columns">
                        <input class="tiny button" type="submit" value="GO" />
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div style="max-width: 90.5rem;" class="row">
        <div class="large-12 columns">
            <table style="width:100%;">
                <thead>
                    <tr>
                        <th></th>
                        <th>Date</th>
                        <th>Sensor</th>
                        <th>Country</th>
                        <th>Src IP</th>
                        <th>Dst port</th>
                        <th>Protocol</th>
                        <th>Honeypot</th>
                    </tr>
                </thead>
                <tbody>
                    {% for at in attacks.items %}
                    <tr>
                        <td>{{ loop.index }}</td>
                        <td>{{ at.timestamp|fdate }}</td>
                        <td>{{ get_sensor_name(at.identifier) }}</td>
                        <td><img src="{{ get_flag_ip(at.source_ip) }}" width=25 height=50 /></td>
                        <td>{{ at.source_ip }}</td>
                        <td>{{ at.destination_port }}</td>
                        <td>{{ at.protocol }}</td>
                        <td>{{ at.honeypot }}</td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            {% from "pagination.html" import render_pagination %}
            {{ render_pagination(attacks, view, request.args.to_dict()) }}
        </div>
    </div>
{% endblock %}
